#include <reg52.h>

sbit d1 = P1^0;
sbit k1 = P3^4;
sbit dula = P2^6;
sbit wela = P2^7;

unsigned char i = 0;
unsigned int code table[] = {
			0x3f, 0x06, 0x5b, 0x4f,
			0x66, 0x6d, 0x7d, 0x07,
			0x7f, 0x6f };

void delay(unsigned int k)
{
	unsigned int i, j;
	for(j = k; j > 0; j--)
		for(i = 110; i > 0; i--);
}


void main()
{
	wela = 1;
	P0 = 0xfe;
	wela = 0;
	
	P3 = 0xff;
	while (1)
	{
		if (k1 == 0)
		{
			delay(5);
			if (k1 == 0)
			{
				i++;
				if (i == 10)
					i = 0;
				d1 = 0;
			}
			while (!k1);
			delay(5);
			while (!k1);
		}
		else
			d1 = 1;
		
		dula = 1;
		P0 = table[i];
		dula = 0;
	}
}